package cn.star.jots.filmSubject.controller;

import cn.star.jots.base.response.JsonResult;
import cn.star.jots.filmSubject.pojo.dto.FilmSubjectQuery;
import cn.star.jots.filmSubject.pojo.dto.FilmSubjectSaveParam;
import cn.star.jots.filmSubject.pojo.vo.FilmSubjectVO;
import cn.star.jots.filmSubject.service.FSService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/filmSubject")
@Api(tags = "电影专题管理")
@Slf4j

public class FSController {

    @Autowired
    FSService fsService;

    @GetMapping("/select")
    @ApiOperation(value = "查询专题里的电影")
    public JsonResult selectAll(FilmSubjectQuery filmSubjectQuery) {
        log.info("查询电影专题:filmSubjectQuery={}", filmSubjectQuery);
        List<FilmSubjectVO> list = fsService.selectAll(filmSubjectQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("/save")
    @ApiOperation(value = "添加电影至专题")
    public JsonResult save(FilmSubjectSaveParam filmSubjectSaveParam){
        log.info("添加电影至专题:filmSubjectSaveParam={}", filmSubjectSaveParam);
        fsService.save(filmSubjectSaveParam);
        return JsonResult.ok();
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除专题里的电影")
    public JsonResult deleteById(@PathVariable Long id){
        log.info("删除专题里的电影:id={}", id);
        fsService.deleteById(id);
        return JsonResult.ok();
    }
}
